package my1024.utils;

import my1024.model.BoxModel;

public class EventData {
	private EventType eventType;
	private BoxModel oldBox;
	private BoxModel newBox;

	public EventData(EventType eventType) {
		this.eventType = eventType;
	}

	public EventData(EventType eventType, BoxModel box) {
		this.eventType = eventType;
		this.oldBox = box;
	}

	public EventData(EventType eventType, BoxModel oldBox, BoxModel newBox) {
		this.eventType = eventType;
		this.oldBox = oldBox;
		this.newBox = newBox;
	}

	public EventType getEventType() {
		return eventType;
	}

	public void setEventType(EventType eventType) {
		this.eventType = eventType;
	}

	public BoxModel getOldBox() {
		return oldBox;
	}

	public void setOldBox(BoxModel oldBox) {
		this.oldBox = oldBox;
	}

	public BoxModel getNewBox() {
		return newBox;
	}

	public void setNewBox(BoxModel newBox) {
		this.newBox = newBox;
	}

	public void correctPosition(int keyCode) {
		if (null != oldBox) {
			oldBox.correctPosition(keyCode);
		}
		if (null != newBox) {
			newBox.correctPosition(keyCode);
		}

		System.out.println("After correct postion: " + toString());
	}

	public String toString() {
		StringBuilder sb = new StringBuilder("EventData:{");
		sb.append("\n\ttype:").append(eventType);
		sb.append("\n\toldBox:").append((null == oldBox) ? "NULL" : oldBox.toString());
		sb.append("\n\tnewBox:").append((null == newBox) ? "NULL" : newBox.toString());
		sb.append("}");
		return sb.toString();
	}

}
